require "common/Define"
require "framework/BaseController"
require "FairyGUI"
require "Window3"

RenderTextureMain = BaseController:New({mControllerName = "RenderTextureMain"});

function RenderTextureMain:Main()
	-- body
	print("Awake", self);
	RenderTextureMain:Awake();
end

function RenderTextureMain:Awake()
	print(self);
	-- body
	Application.targetFrameRate = 60;
	Stage.inst.onKeyDown:Add(self.OnKeyDown);

	-- load view
	-- attack pacakge, package in resource or assetbundle
	local packageName = "UI/RenderTexture";
	UIPackage.AddPackage(packageName);

	local componentName = "Main";
	self.mainComponent = UIPackage.CreateObject("RenderTexture", componentName).asCom;
	GRoot.inst:AddChild( self.mainComponent );

	self:OnViewCreated(self.mainComponent);

	self._testWin = Window3.New();
	self.mainComponent:GetChild("n2").onClick:Add( function () self._testWin:Show(); end );
end

function RenderTextureMain:OnKeyDown(context)
	if (context.inputEvent.keyCode == KeyCode.Escape) then
			Application.Quit();
	end
end

